#ifndef FORMMASKS_H
#define FORMMASKS_H

#include <QWidget>
#include <QCheckBox>
#include <QTimer>

namespace Ui {
class FormMasks;
}

struct kbRGB_ctrl_t {
    uint8_t slave_init;
    uint8_t cols;
    uint8_t rows;
    uint8_t IdxMode;
    uint8_t IdxLogo;
    uint8_t Speed;
    uint8_t reverse;
    uint32_t background; // rgb
    uint32_t logo;       // rgb
    uint32_t keys[8];    // 按键状态, Bit Map数据,每3字节表示一行([R0,R7],[R8,R15],[R16,R23]),每 bit表示对应键位上按键状态, 0:无按键按下;1:按键按下;
    uint32_t Palettes[8];
    uint32_t Masks[8];
    uint8_t normally;
    uint32_t reverseX;
    uint32_t reverseY;
    int Horizontal=0;
};

class FormMasks : public QWidget
{
    Q_OBJECT

public:
    explicit FormMasks(QWidget *parent = nullptr);
    ~FormMasks();

    static const struct kbRGB_ctrl_t* Get(void) { return &ctrl; }
private slots:
    void timer_update(void);

    void on_comboBox_Demo_currentIndexChanged(int index);

    void on_comboBox_Dir_currentIndexChanged(int index);

    void on_comboBox_Start_currentIndexChanged(int index);

    void on_comboBox_Logo_currentIndexChanged(int index);

private:
    void masks_update(void);
    void scan_demo(const uint32_t reverseX, const uint32_t reverseY);
    //void kb_map_update(uint32_t masks[8], uint8_t cols, uint8_t rows, const uint8_t kb_map[6][21]);
    void KB_Scanning(void);
    void masks_show(void);

private:
    Ui::FormMasks *ui;
    static const uint8_t cols,rows;
    QCheckBox *checkBoxs[8][32];
    //uint32_t Masks[8];
//    uint32_t reverseX;
//    uint32_t reverseY;
//    int Horizontal=0;
    int ZigZag=0;
    int scanning;
    double Progress;
    QTimer timer_masks;
    static struct kbRGB_ctrl_t ctrl;
};

#endif // FORMMASKS_H
